﻿#encoding:utf-8
import os
from word import *

class DIR:
	def __init__(self):
		#在此添加您的需要遍历的目录
		self.dir1='C:\ProgramData\Microsoft\Windows\Start Menu\Programs'
		self.dir2='C:\Users\JoneWang\AppData\Roaming\Microsoft\Windows\Start Menu\Programs'
		
	def getapplist(self,filename):
		isrun=True
		list_apps={}
		list_apps=self._walk_dir(filename,self.dir1,list_apps)
		#list_apps=self._walk_dir(filename,self.dir2,list_apps)
		return list_apps
		
	def _walk_dir(self,filename,dir,list,topdown=True):
		word=WORD()
		for root,dirs,files in os.walk(dir,topdown):
			for name in files:
				name=name.decode('gb2312')
				if word.get(filename,name):
					list[name]=os.path.join(root.decode('gb2312').encode('utf-8').decode('utf-8'),name)
					isrun=False
		return list